/*
 * @Author: szx
 * @Date: 2023-04-17 11:12:21
 * @LastEditTime: 2023-04-17 11:43:20
 * @Description: 
 * @FilePath: \learn\fullstackopen\unicafe-redux-main\src\reducer.js
 */
const initialState = {
  good: 0,
  ok: 0,
  bad: 0
}

const counterReducer = (state = initialState, action) => {
  console.log(action)
  switch (action.type) {
    case 'GOOD':
      return {
        ...state,
        good: state.good + 1
      }
    case 'OK':
      return {
        ...state,
        ok: state.ok + 1
      }
    case 'BAD':
      return {
        ...state,
        bad: state.bad + 1
      }
    case 'ZERO':
      return {
        ...initialState
      }
    default: return state
  }

}

export default counterReducer
